#include <cppr.hpp>
#include <memory>
using namespace std;
class a
{
private:
    int x = 10;

public:
    void print()
    {
        auto func = [this]()
        {
            cout << this->x << endl;
        };
        func();
    }

    ~a()
    {
        cout << "a的析构函数" << endl;
    }
};

shared_ptr<a> p1;
void test()
{
    cout << p1.use_count() << endl;
    shared_ptr<a> p = make_shared<a>(); // make_shared函数创建一个智能指针
    p->print();
    cout << p.use_count() << endl;
    p1 = p;
}

int main(int argc, char const *argv[])
{
    test();
    p1 = make_shared<a>();
    cout << p1.use_count() << endl; // 打印p1的引用计数
    cout << "1111" << endl;
    return 0;
}
